//
//  YWMaterialManager.h
//  maintain
//
//  Created by 烟雨云渊 on 16/9/1.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YWSingleton.h"

@class YWHandler;
@class YWMaterialStock;
@class YWMaterial;
@class YWMaterialApply;
@class YWMaterialApplyDetail;
@class YWMaterialApplyViewModel;
@class YWMaterialRelation;
@class YWMaterialStockOut;
@class YWMaterialStockOutDetail;
@class YWMaterialReturn;


static NSString *const KPostCancelApplyNotification = @"KPostCancelApplyNotification";
static NSString *const KPostCommitApplyMaterialSuccessNotification = @"KPostCommitApplyMaterialSuccessNotification";
static NSString *const KPostHaveStockOutBackNotification = @"KPostHaveStockOutBackNotification";
static NSString *const KPostBackToApplyTableViewNotification = @"KPostBackToApplyTableViewNotification";

static NSString *const KPostStockOutCertainAfterRefreshRecordViewNoti = @"KPostStockOutCertainAfterRefreshRecordViewNoti";
static NSString *const KPostReturnCertainAfterRefreshNotification = @"KPostReturnCertainAfterRefreshNotification";
static NSString *const KPostMaterialApplyReplyNotification = @"KPostMaterialApplyReplyNotification";
static NSString *const KPostMaterialStockOutReplyNotification = @"KPostMaterialStockOutReplyNotification";
static NSString *const KPostMaterialReturnReplyNotification = @"KPostMaterialReturnReplyNotification";
static NSString *const KPostMaterialNoScanSureNotification = @"KPostMaterialNoScanSureNotification";
@interface YWMaterialManager : NSObject
YWSingletonH(Manager)

#pragma mark - 库存表的更新、取值

/**
 *  更新库存表，数组更新
 *
 *  @param materialStockArray 库存model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialStockWithArray:(NSArray*)materialStockArray;
/**
 *  获取库存表
 *
 *  @param page 页数
 *
 *  @return 结果
 */
- (NSArray *)materialStockWithPage:(NSInteger)page;
#pragma mark - 更新物料信息表的更新、取值

/**
 *  更新物料信息表，数组更新
 *
 *  @param materialInfoArray 物料信息model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialInfoWithArray:(NSArray*)materialInfoArray;
/**
 *  获取申请表
 *
 *  @param materialInfoId 物料信息Id
 *
 *  @return 结果
 */
//- (YWMaterialApply *)materialApplyWithMaterialInfoId:(NSInteger)materialInfoId;
#pragma mark - 物料申请表的更新、取值
/**
 *  更新物料数据状态
 *
 *  @param applyId 物料id
 *
 *  @return 结果
 */
- (BOOL)updateMaterialStatus:(NSInteger)status withApplyId:(NSInteger)applyId;
/**
 *  删除物料申请单
 *
 *  @param applyId 物料id
 *
 *  @return 结果
 */
- (BOOL)deleteMaterialApplyWithApplyId:(NSInteger)applyId;
/**
 *  更新物料申请状态（业务）
 *
 *  @param applyId 物料id
 *
 *  @return 结果
 */
- (BOOL)updateMaterialApplyStatus:(NSInteger)applyStatus withApplyId:(NSInteger)applyId;
/**
 *  更新物料申请表，数组更新
 *
 *  @param materialApplyArray 更新物料申请model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialApplyWithArray:(NSArray*)materialApplyArray;
/**
 *  获取物料申请表
 *
 *  @param page 页数
 *
 *  @return 结果
 */
- (NSArray *)materialApplyWithPage:(NSInteger)page;
/**
 *  获取物料申请表
 *
 *  @param materialApplyId 页数
 *
 *  @return 结果
 */
- (YWMaterialApplyViewModel *)materialApplyWithMaterialApplyId:(NSInteger)materialApplyId;
/**
 *  获取物料申请表
 *
 *  @param materialStockOutId 领用单Id
 *
 *  @return 结果
 */
- (YWMaterialApplyViewModel *)materialApplyWithMaterialStockOutId:(NSInteger)materialStockOutId;
#pragma mark - 物料申请明细表的更新、取值

/**
 *  更新物料申请明细表，数组更新
 *
 *  @param materialApplyDetailArray 更新物料申请明细model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialApplyDetailWithArray:(NSArray*)materialApplyDetailArray;
/**
 *  获取物料申请明细表
 *
 *  @param materialApplyDetailId 申请物料详情Id
 *
 *  @return 结果
 */
- (YWMaterialApplyDetail *)materialApplyDetailWithMaterialApplyDetailId:(NSInteger)materialApplyDetailId;
#pragma mark - 物料领用表的更新、取值
/**
 *  删除物料领用单
 *
 *  @param stockOutId 物料领用id
 *
 *  @return 结果
 */
- (BOOL)deleteMaterialStockOutWithStockOutId:(NSInteger)stockOutId;
/**
 *  更新物料领用状态
 *
 *  @param stockOutId 出库单id
 *
 *  @return 结果
 */
- (BOOL)updateMaterialStockOutStatusWithStockOutId:(NSInteger)stockOutId;
/**
 *  更新物料领用表，数组更新
 *
 *  @param materialApplyDetailArray 更新物料申请明细model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialReceipientWithArray:(NSArray*)materialReceipientArray;
/**
 *  获取物料领用表
 *
 *  @param page 页数
 *
 *  @return 结果
 */
- (NSArray*)materialReceipientWithPage:(NSInteger)page;
/**
 *  获取物料领用表信息
 *
 *  @param materialReceipientId  领用Id
 *
 *  @return 结果
 */
- (YWMaterialStockOut*)materialReceipientWithMaterialReceipientId:(NSInteger)materialReceipientId;
#pragma mark - 物料领用明细表更新、取值
/**
 *  更新物料领用明细表，数组更新
 *
 *  @param materialReceipientDetailArray 更新物料领用明细model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialReceipientDetailWithArray:(NSArray*)materialReceipientDetailArray;
#pragma mark - 物料归还表更新、取值
/**
 *  更新物料归还表，数组更新
 *
 *  @param materialReturnArray 更新物料归还model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialReturnWithArray:(NSArray*)materialReturnArray;
/**
 *  更新物料归还状态
 *
 *  @param returnId 归还Id
 *
 *  @return 结果
 */
- (BOOL)updateMaterialReturnStatusWithMaterialReturnId:(NSInteger)returnId;
/**
 *  删除物料归还单
 *
 *  @param returnId 物料归还id
 *
 *  @return 结果
 */
- (BOOL)deleteMaterialReturnWithReturnId:(NSInteger)returnId;
/**
 *  获取物料归还表
 *
 *  @param page 页数
 *
 *  @return 结果
 */
- (NSArray*)materialReturnWithPage:(NSInteger)page;
/**
 *  获取物料归还表信息
 *
 *  @param materialReturnId  归还Id
 *
 *  @return 结果
 */
- (YWMaterialReturn*)materialReturnWithMaterialReturnId:(NSInteger)materialReturnId;

#pragma mark - 物料归还明细表的更新、取值
/**
 *  更新物料归还明细表，数组更新
 *
 *  @param materialReturnDetailArray 更新物料归还model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialReturnDetailWithArray:(NSArray*)materialReturnDetailArray;
#pragma mark - 物料关系表更新、取值
/**
 *  更新物料关系表，数组更新
 *
 *  @param materialRelationArray 更新物料关系model数组
 *
 *  @return 结果
 */
- (BOOL)updateMaterialRelationWithArray:(NSArray*)materialRelationArray;
/**
 *  获取物料关系表信息
 *
 *  @param materialApplyId  关系Id
 *
 *  @return 结果
 */
- (YWMaterialRelation*)materialRelationWithMaterialApplyId:(NSInteger)materialApplyId;
/**
 *  获取物料关系表信息
 *
 *  @param materialReceipientId  关系Id
 *
 *  @return 结果
 */
- (YWMaterialRelation*)materialRelationWithMaterialReceipientId:(NSInteger)materialReceipientId;
/**
 *  获取物料关系表信息
 *
 *  @param materialReturnId  关系Id
 *
 *  @return 结果
 */
- (YWMaterialRelation*)materialRelationWithMaterialReturnId:(NSInteger)materialReturnId;
/**
 *  更新物料流转信息表
 *
 *  数组更新
 *
 *  @return 结果
 */
- (BOOL)updateMaterialCirculationInfoWithArray:(NSArray*)circulationInfoArray;
/**
 *  获取物料流转信息表信息
 *
 *  @param materialRelationId  关系Id
 *
 *  @return 结果
 */
- (NSArray *)materialCirculationInfoArrayWithMaterialRelationId:(NSInteger)materialRelationId;
#pragma mark - 接口数据请求及提交
/**
 *  请求物料申请
 *
 *  @return 结果
 */
- (void)requestMaterialApplyListInfoPage:(NSInteger)page Status:(NSInteger)status WithComplete:(void(^)(BOOL success))complete;
/**
 *  请求单个物料申请
 *
 *  @return 结果
 */
- (void)requestMaterialApplyWithApplyId:(NSInteger)applyId Complete:(void(^)(YWMaterialApply* materialApply))complete;
/**
 *  请求物料领用
 *
 *  @return 结果
 */
- (void)requestMaterialReceipientListInfoPage:(NSInteger)page Status:(NSInteger)status WithComplete:(void(^)(BOOL success))complete;
/**
 *  请求物料归还
 *
 *  @return 结果
 */
- (void)requestMaterialBackListInfoPage:(NSInteger)page Status:(NSInteger)status WithComplete:(void(^)(BOOL success))complete;
/**
 *  查询物料清单
 *
 *  @return 结果
 */
- (void)requestSearchMaterialListWithBuildingId:(NSString *)buildingId SearchCondition:(NSString *)searchCondition page:(NSInteger)page WithComplete:(void(^)(NSArray *searchResult,NSInteger statusCode))complete;
/**
 *  扫描出库二维码
 *
 *  @return 结果
 */
- (void)scanMaterialReceipientQrcodeWithStockOutId:(NSInteger)stockOutId creatorId:(NSInteger)creatorId isScan:(BOOL)isScan WithComplete:(void(^)(BOOL success))complete;
/**
 *  扫描归还二维码
 *
 *  @return 结果
 */
- (void)scanMaterialReturnQrcodeWithReturnId:(NSInteger)returnId creatorId:(NSInteger)creatorId isScan:(BOOL)isScan WithComplete:(void(^)(BOOL success))complete;
/**
 *  撤回物料申请
 *
 *  @return 结果
 */
- (void)materialApplyDeleteWithApplyId:(NSInteger)applyId WithComplete:(void(^)(NSInteger stateCode))complete;
/**
 *  增加抄送人
 *
 *  @return 结果
 */
- (void)materialAddMoreCopiesWithApplyId:(NSInteger)applyId CarbonCopies:(NSArray *)copyIds Note:(NSString *)note WithComplete:(void(^)(BOOL success))complete;
/**
 *  创建物料申请单
 *
 *  @return 结果
 */
- (void)createMaterialApplyWithBuildingId:(NSString*)buildingId Receivers:(NSArray*)recipients CarbonCopy:(NSArray*)copiers Note:(NSString*)note MaterialInfo:(NSArray*)details WithComplete:(void(^)(BOOL success))complete;
/**
 *  确认出库信息
 *
 *  @return 结果
 */
- (void)certurnMaterialStockoutWithBuildingId:(NSString*)buildingId CreatorId:(NSInteger)creatorId StockOutId:(NSInteger)stockOutId WithComplete:(void(^)(BOOL success))complete;
/**
 *  确认归还信息
 *
 *  @return 结果
 */
- (void)certurnMaterialReturnWithBuildingId:(NSString*)buildingId CreatorId:(NSInteger)creatorId ReturnId:(NSInteger)returnId WithComplete:(void(^)(BOOL success))complete;
/**
 *  新建评论
 *
 *  @return 结果
 */
- (void)commitMaterialReplyContent:(NSString*)content atUser:(YWHandler*)atUser Type:(NSInteger)type RelationId:(NSInteger)relationId WithComplete:(void(^)(BOOL success))complete
;
/**
 *  (仓库发放人）物料出库确认
 *
 *  @return 结果
 */
- (void)postMaterialStockOutCerturnWithReceiver:(YWHandler*)receiver stockOut:(YWMaterialStockOut*)stockOut WithComplete:(void(^)(BOOL success))complete;
/**
 *  (归还人）物料归还确认
 *
 *  @return 结果
 */
- (void)postMaterialReturnBackCerturnWithCreator:(YWHandler*)creator returnBack:(YWMaterialReturn*)returnBack WithComplete:(void(^)(BOOL success))complete;
/**
 *  (接收人）确认出库
 *
 *  @return 结果
 */
- (void)postMaterialStockOutReceiveCerturnWithStockOutId:(NSInteger)stockOutId WithComplete:(void(^)(BOOL success))complete;
/**
 *  (接收人）拒绝出库
 *
 *  @return 结果
 */
- (void)postMaterialStockOutRejectWithStockOutId:(NSInteger)stockOutId note:(NSString*)note WithComplete:(void(^)(BOOL success))complete;
/**
 *  (仓库接收人）确认归还
 *
 *  @return 结果
 */
- (void)postMaterialReturnBackCerturnWithReturnId:(NSInteger)returnId WithComplete:(void(^)(BOOL success))complete;
/**
 *  (仓库接收人）拒绝归还
 *
 *  @return 结果
 */
- (void)postMaterialReturnBackRejectWithReturnId:(NSInteger)returnId note:(NSString*)note WithComplete:(void(^)(BOOL success))complete;
@end
